package com.haozi.security.autoconfig;

import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import com.haozi.security.config.SignConfig;
import com.haozi.security.vertify.SignAdvice;
import com.haozi.security.vertify.SignVertify;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author zyh
 * @version 1.0
 * @date 2022/11/5 4:04 下午
 */
@Configuration
@ConditionalOnProperty("sign.config.secret")
public class SignAutoConfig {

    /**
     * 全局配置
     *
     * @return
     */
    @Bean
    @ConfigurationProperties(prefix = "sign.config")
    public SignConfig config() {
        return new SignConfig();
    }

    /**
     * 织入验签逻辑
     *
     * @return
     */
    @Bean
    public SignAdvice signAdvice() {
        return new SignAdvice();
    }

    /**
     * 签名校验类
     *
     * @return
     */
    @Bean
    public SignVertify signVertify() {
        return new SignVertify();
    }

}
